package Classroom;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class UDPReceive {
    public static void main(String[] args) throws Exception {
        //创建一个接收端
        DatagramSocket ds = new DatagramSocket(10000);

        //创建一个接受它的数据,接受那边数据放入
        byte [] bytes = new byte[1024*8];
        DatagramPacket dp = new DatagramPacket(bytes, bytes.length);
        //接受
        ds.receive(dp);
        //获取
        byte[] data = dp.getData();
        System.out.println(new String(data));
        //释放
        ds.close();
    }
}
